﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Metriks.Parsiranje.Klase
{
    public class varAssign : LOC, Renameable
    {
        public String varijablaNaziv;
        public String izraz;

        public varAssign(String[] parametri)
        {
            varijablaNaziv = parametri[0];
            izraz = parametri[1];
        }

        public override string ispiši()
        {
            return varijablaNaziv + "=" + izraz + ";";
        }

        public void renameVariable(String oldname, String newname)
        {
            if (varijablaNaziv == oldname)
                varijablaNaziv = newname;
            Regex r = new Regex(@"\b" + oldname + @"\b");
            izraz = r.Replace(izraz, newname);
        }
    }
}
